//
//  CellForDestination_sontents.m
//  SeeTheWorld
//
//  Created by dllo on 16/1/27.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CellForDestination_sontents.h"
#import "PCH.pch"
#import "ModelForDestination_contents.h"
#import <UIImageView+WebCache.h>


@interface CellForDestination_sontents () <UIWebViewDelegate>

// 左边imageView.
@property (nonatomic, retain) UIImageView *imageViewForLeft;
// 夜间模式下imageView 上的view.
@property (nonatomic, retain) UIView *viewForBackground;
// title.
@property (nonatomic, retain) UILabel *labelForTitle;
// 游记下面的view.
@property (nonatomic, retain) UIView *viewForTravels;
// 游记的篇数.
@property (nonatomic, retain) UILabel *labelForTravels;
// 内容.
@property (nonatomic, retain) UILabel *labelForDescription;

@end

@implementation CellForDestination_sontents

- (void)dealloc {
    [_imageViewForLeft release];
    [_viewForBackground release];
    [_labelForTitle release];
    [_viewForTravels release];
    [_labelForTravels release];
    [_labelForDescription release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createSubViews];
        
        
        
    }
    
    return self;
}

#pragma mark ** 创建子视图
- (void)createSubViews {
    
    self.imageViewForLeft = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewForLeft];
    [_imageViewForLeft release];
    
    
    self.viewForBackground = [[UIView alloc] init];
    self.viewForBackground.dk_backgroundColorPicker = DKColorWithColors([UIColor lightGrayColor], [UIColor blackColor]);
    self.viewForBackground.alpha = 0.1;
    [self.contentView addSubview:self.viewForBackground];
    [_viewForBackground release];
    
    
    self.labelForTitle = [[UILabel alloc] init];
    self.labelForTitle.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:self.labelForTitle];
    [_labelForTitle release];
    self.labelForTitle.dk_textColorPicker = DKColorWithRGB(0x343434, 0xffffff);

    self.viewForTravels = [[UIView alloc] init];
    self.viewForTravels.backgroundColor = [UIColor blackColor];
    self.viewForTravels.alpha = 0.4;
    [self.contentView addSubview:self.viewForTravels];
    [_viewForTravels release];
    
    
    self.labelForTravels = [[UILabel alloc] init];
    self.labelForTravels.font = [UIFont systemFontOfSize:10];
    self.labelForTravels.textAlignment = 1;
    self.labelForTravels.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.labelForTravels];
    [_labelForTravels release];

    self.labelForDescription = [[UILabel alloc] init];
    self.labelForDescription.font = [UIFont systemFontOfSize:12];
    self.labelForDescription.numberOfLines = 0;
    [self.contentView addSubview:self.labelForDescription];
    [_labelForDescription release];
    self.labelForDescription.dk_textColorPicker = DKColorWithRGB(0x343434, 0xffffff);
    
    
}

#pragma mark ** 实现方法
- (void)voluationToCellForForeignSubViewsWithModel:(ModelForDestination_contents *)model {
    
    [self.imageViewForLeft sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"1f178a82b9014a90e9109296ad773912b31beeeb"]];
    
    self.labelForTitle.text = model.name;
    
    self.labelForTravels.text = [NSString stringWithFormat:@"%ld 篇游记", (long)model.attraction_trips_count];
    
    self.labelForDescription.text = model.description_summary;
    
}

#pragma mark ** 布局子视图
- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.imageViewForLeft.frame = CGRectMake(10, 10, (scWIDTH - 10) / 3, scHEIGHT - 15);
    
    self.viewForBackground.frame = self.imageViewForLeft.frame;
    
    self.labelForTitle.frame = CGRectMake(self.imageViewForLeft.frame.origin.x + self.imageViewForLeft.frame.size.width + 10, 10, scWIDTH - self.imageViewForLeft.frame.origin.x - self.imageViewForLeft.frame.size.width - 10, 20);
    
    self.viewForTravels.frame = CGRectMake(10, scHEIGHT - 25, self.imageViewForLeft.frame.size.width, 20);
    
    self.labelForTravels.frame = self.viewForTravels.frame;
    
    self.labelForDescription.frame = CGRectMake(self.labelForTitle.frame.origin.x, self.labelForTitle.frame.origin.y + self.labelForTitle.frame.size.height, self.labelForTitle.frame.size.width, scHEIGHT - self.labelForTitle.frame.origin.y - self.labelForTitle.frame.size.height);
    
}








- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
